Arduino Cookbook by Michael Margolis
Author:Michael Margolis [Michael Margolis]
Language: eng
Format: epub, mobi
Tags: TECHNOLOGY & ENGINEERING / Robotics
ISBN: 9781449313906
Publisher: O'Reilly Media
Published: 2011-12-11T16:00:00+00:00
Note
You won’t see anything when the codes are sent because the light from the infrared LED isn’t visible to the naked eye.
However, you can verify that an infrared LED is working with a digital camera—you should be able to see it flashing in the camera’s LCD viewfinder.
Figure 10-2. Buttons and LED for IR sender
Discussion
Here Arduino controls the device by flashing an IR LED to duplicate the signal that would be sent from your remote control. This requires an IR LED. The specifications are not critical; see Appendix A for suitable components.
The IR library handles the translation from numeric code to IR LED flashes. You need to create an object for sending IR messages. The following line creates an IRsend object that will control the LED on pin 3 (you are not able to specify which pin to use; this is hardcoded within the library):
IRsend irsend;
The code uses an array (see Recipe 2.4) called irKeyCodes to hold the range of values that can be sent. It monitors five switches to see which one has been pressed and sends the relevant code in the following line:
irsend.sendSony(irKeyCodes[keyNumber], 32);
The irSend object has different functions for various popular infrared code formats, so check the library documentation if you are using one of the other remote control formats. You can use Recipe 10.2 if you want to display the format used in your remote control.
The sketch passes the code from the array, and the number after it tells the function how many bits long that number is. The 0x at the beginning of the numbers in the definition of irKeyCodes at the top of the sketch means the codes are written in hex (see Chapter 2 for details about hex numbers). Each character in hex represents a 4-bit value. The codes here use eight characters, so they are 32 bits long.
The LED is connected with a current-limiting resistor (see the introduction to Chapter 7).
If you need to increase the sending range, you can use multiple LEDs or select one with greater output.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Circuits | Digital Design |
Electric Machinery & Motors | Electronics |
Fiber Optics | Networks |
Superconductivity |
Whiskies Galore by Ian Buxton(41454)
Introduction to Aircraft Design (Cambridge Aerospace Series) by John P. Fielding(32827)
Small Unmanned Fixed-wing Aircraft Design by Andrew J. Keane Andras Sobester James P. Scanlan & András Sóbester & James P. Scanlan(32511)
Craft Beer for the Homebrewer by Michael Agnew(17880)
Turbulence by E. J. Noyes(7619)
The Complete Stick Figure Physics Tutorials by Allen Sarah(7070)
Kaplan MCAT General Chemistry Review by Kaplan(6505)
The Thirst by Nesbo Jo(6371)
Bad Blood by John Carreyrou(6221)
Modelling of Convective Heat and Mass Transfer in Rotating Flows by Igor V. Shevchuk(6184)
Learning SQL by Alan Beaulieu(5961)
Weapons of Math Destruction by Cathy O'Neil(5723)
Man-made Catastrophes and Risk Information Concealment by Dmitry Chernov & Didier Sornette(5520)
Digital Minimalism by Cal Newport;(5272)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5105)
iGen by Jean M. Twenge(5095)
Secrets of Antigravity Propulsion: Tesla, UFOs, and Classified Aerospace Technology by Ph.D. Paul A. Laviolette(4810)
Design of Trajectory Optimization Approach for Space Maneuver Vehicle Skip Entry Problems by Runqi Chai & Al Savvaris & Antonios Tsourdos & Senchun Chai(4782)
Electronic Devices & Circuits by Jacob Millman & Christos C. Halkias(4659)
